Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHI 1 - Labeled Tuples #4

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft

PHI 1 - Labeled Tuples #4

wants to merge 13 commits into from

Conversation

ecdeuts
Copy link
Contributor

@ecdeuts ecdeuts commented May 12, 2020

No description provided.

@ecdeuts ecdeuts requested a review from cyrus- May 12, 2020 19:32
@ecdeuts ecdeuts marked this pull request as draft May 12, 2020 19:32
@cyrus- cyrus- changed the title 1 labeled tuples PHI 1 - Labeled Tuples May 12, 2020
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved

### Expression Syntax Errors

+ A label must be followed by a valid expression and comma operator, not another label. For example, `.label1 .label2 e` produces an error.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments above on types

1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
@ecdeuts ecdeuts marked this pull request as ready for review May 19, 2020 18:52
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
TODO: partially labeled values, where some of the arguments are in order: `(1, 2, .z 3) <= (.x Num, .y Num, .z Num)`. what about interleaving vs. requiring all the explicit labels at the end ala Python?
TODO: what are the type synthesis and type analysis rules for the labeled tuple expressions -->
### Punning
Some languages, such as Reason, have record punning. This is where a record's labels can be implied when it is declared using variables. For example, `{x, y, z} => {x: x, y: y, z: z}` is true. Similar punning fuctionality could be implemented in Hazel. For example, if this punning was implemented `(x, y, z) => (x: x, y: y, z: z)` would hold true. However, this creates a question of if every tuple created with variables should be a labeled tuple. Given this additional complexity and added development costs, I believe that labeled tuple punning should be considered out of scope for labeled tuples.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give the ambiguous example: (y, x, z) -- is this punned or ordered?

1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
1-labeled-tuples/1-labeled-tuples.md Outdated Show resolved Hide resolved
`e.label` will be the new expression form. `e.label` expects `e` to synthesize to a labeled tuple type and `label` to match one of the labels within `e`.

`e.label` will return the value that has the label `label`.
#### Backspace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate section on Action Semantics

![Synthesis Rule for Projection](syn_1.png)

#### Analysis
![Analysis Rule Single](ana_1.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't want to allow a type to be treated as a 1-tuple implicitly, so don't need this rule.

@cyrus- cyrus- marked this pull request as draft May 19, 2020 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants